package o;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.text.TextUtils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.io.StreamCorruptedException;
import java.util.Set;

public abstract class BaseSharedPref {
    protected SharedPreferences ˏ = ContentManager.getInstant().getContext().getApplicationContext().getSharedPreferences("PoorNetDownloadRecord", 0);

    public boolean ॱॱ(String str) {
        return this.ˏ.contains(str);
    }

    public void ˑ() {
        try {
            this.ˏ.edit().commit();
        } catch (Throwable e) {
            Logger.ˋ("BaseSharedPref", "commit error!!:", e);
        }
    }

    public void ˏˏ() {
        try {
            Editor edit = this.ˏ.edit();
            edit.clear();
            edit.commit();
        } catch (Throwable e) {
            Logger.ˋ("BaseSharedPref", "clear error!!,", e);
        }
    }

    public void ˋ(String str, String str2) {
        try {
            Editor edit = this.ˏ.edit();
            edit.putString(str, str2);
            edit.commit();
        } catch (Exception e) {
            Logger.e("BaseSharedPref", "putString error!!key:" + str);
        }
    }

    public void ˋ(String str, Set<String> set) {
        try {
            Editor edit = this.ˏ.edit();
            edit.putStringSet(str, set);
            edit.commit();
        } catch (Exception e) {
            Logger.e("BaseSharedPref", "putStringSet error!!key:" + str);
        }
    }

    public void ˎ(String str, long j) {
        try {
            Editor edit = this.ˏ.edit();
            edit.putLong(str, j);
            edit.commit();
        } catch (Exception e) {
            Logger.e("BaseSharedPref", "putLong error!!key:" + str);
        }
    }

    public void ˋ(String str, boolean z) {
        try {
            Editor edit = this.ˏ.edit();
            edit.putBoolean(str, z);
            edit.commit();
        } catch (Exception e) {
            Logger.e("BaseSharedPref", "putBoolean error!!key:" + str);
        }
    }

    public void ˊ(String str, int i) {
        try {
            Editor edit = this.ˏ.edit();
            edit.putInt(str, i);
            edit.commit();
        } catch (Exception e) {
            Logger.e("BaseSharedPref", "putInt error!!key:" + str);
        }
    }

    public String ॱ(String str, String str2) {
        try {
            str2 = this.ˏ.getString(str, str2);
        } catch (Exception e) {
            this.ˏ.edit().remove(str).commit();
        }
        return str2;
    }

    public Set<String> ॱ(String str, Set<String> set) {
        try {
            Set<String> stringSet = this.ˏ.getStringSet(str, set);
            return stringSet == null ? set : stringSet;
        } catch (Exception e) {
            this.ˏ.edit().remove(str).commit();
            return set;
        }
    }

    public long ॱ(String str, long j) {
        try {
            j = this.ˏ.getLong(str, j);
        } catch (Exception e) {
            this.ˏ.edit().remove(str).commit();
        }
        return j;
    }

    public boolean ˏ(String str, boolean z) {
        try {
            z = this.ˏ.getBoolean(str, z);
        } catch (ClassCastException e) {
            this.ˏ.edit().remove(str).commit();
        }
        return z;
    }

    public int ॱ(String str, int i) {
        try {
            i = this.ˏ.getInt(str, i);
        } catch (ClassCastException e) {
            this.ˏ.edit().remove(str).commit();
        }
        return i;
    }

    public void ʼ(String str) {
        try {
            Editor edit = this.ˏ.edit();
            edit.remove(str);
            edit.commit();
        } catch (Exception e) {
            Logger.e("baseSharedPre", "remove error key:" + str);
        }
    }

    public void ˋ(String str, Serializable serializable) {
        OutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        try {
            new ObjectOutputStream(byteArrayOutputStream).writeObject(serializable);
            ˋ(str, dnk.ˏ(byteArrayOutputStream.toByteArray()));
        } catch (IOException e) {
            Logger.e("BaseSharedPref", "putSerializable :saveObject failed!!");
        }
    }

    public Serializable ʻ(String str) {
        Object ॱ = ॱ(str, "");
        if (TextUtils.isEmpty(ॱ)) {
            return null;
        }
        byte[] ˎ = dnk.ˎ(ॱ);
        if (ˎ == null || ˎ.length <= 0) {
            return null;
        }
        Serializable serializable;
        try {
            serializable = (Serializable) new ObjectInputStream(new ByteArrayInputStream(ˎ)).readObject();
        } catch (StreamCorruptedException e) {
            Logger.e("BaseSharedPref", "getObject failed!!: StreamCorruptedException");
            serializable = null;
        } catch (IOException e2) {
            Logger.e("BaseSharedPref", "getObject failed!!: IOException");
            serializable = null;
        } catch (ClassNotFoundException e3) {
            Logger.e("BaseSharedPref", "getObject failed!!: ClassNotFoundException");
            serializable = null;
        } catch (Exception e4) {
            Logger.e("BaseSharedPref", "getObject failed!!: Exception");
            serializable = null;
        }
        return serializable;
    }
}
